<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class default_controller extends base_controller {
    public $default_model ;
    public function __construct() {
        $exception = array("");
        $redirectPara = array("module"=>"login",
                              "controller"=>"login",
                              "action"=>"index",
                              "exception"=>$exception);
        parent::__construct('',$session = true ,'uid' ,$redirectPara );
        Magic::callMethod()->importLibarary("Magic_CRUD_Model");
        $this->default_model = new default_model();
            
    }
    public function indexController(){
       
        $this->nmessage = $this->default_model->sayHello();
        //$this->footer = Template::renderTemplate("admin_footer",TEMPLATE_PATH);
        if(@$_GET["msg"] == '') {
            $this->msg = '';
        } else {
            $this->msg = $_GET["msg"];
        }

    }
    public function printPostArrayController(){
       $f = array("f_name","address","city");
       $d = $_POST ;
        Magic_Connection_Model::callMethod()->connectionOpen();
        if(Magic_CRUD_Model::callMethod()->insertData("employee",$f,$d,0,'','',0,0)) {
            $msg = "Success !";
        } else {
            $msg = "Fail";
        }
        Magic_Connection_Model::callMethod()->connectionClose();
        Magic_Common_Model::callMethod()->_pageRedirect(SITE_URL."default/index?msg=".$msg);
    }
    public function listingController(){
        Magic_Connection_Model::callMethod()->connectionOpen();
        $tableName = 'demo_city,demo_master';
        $tableDisplayField = array( "demo_name",
                                    "demo_email",
                                    "demo_address",
                                    "demo_city");
        $tableDisplayTitle = array("Name","Email","Address","City");
        $databaseFetchField = array("demo_city.d_c_id",
                                    "demo_master.demo_name",
                                    "demo_master.demo_email",
                                    "demo_master.demo_address",
                                    "demo_city.demo_city"
                                    );
        $pageName =SITE_URL."default/default/listing";
        $afterWhereConditon = "&& demo_city.demo_master_id = demo_master.demo_master_id ";
        Magic::callMethod()->importLibarary("Magic_CreatePagin_Model",'',false);
        $extraColumnField = array(array("cAfterField"=> "demo_email",
                                  "cName" =>"demo_master_id",
                                  "cAfterTitle" =>"Email",
                                  "cTitle"=> "Master ID" ,
                                  "cDisplayValue"=>'hello'  
                                ));
        $pagingArray_1  =array ("dbTableName" => $tableName,
                            "tableDisplayField" => $tableDisplayField,
                            "tableDisplayFieldTitle" =>$tableDisplayTitle,
                            "databaseFetchField" => $databaseFetchField,
                            "pageName"=>$pageName,
                            "recordPerPage"=>"2", 
                            "noOfLink"=>"2",
                            "joinStatus"=>1 ,
                            "beforeWhereCondition"=> "" ,
                            "afterWhereCondition"=> $afterWhereConditon ,    
                            "activeStatus"=>0,
                            "deleteStatus"=>0,
                            "editStatus"=> 0,
                            "primarykeyFieldName"=>"d_c_id",
                            "debugQuery"=>0,
                            "extraColumnStatus"=>1,
                            "extraColumnArray"=>$extraColumnField,
                            "debugQuery" => 0,
                            "extraLink"=>'<a href="#">Rotate</a>',
                            "extraUrlPara"=>'magic=1&roate=3'
                            );
       // $pagingVar = Magic_CreatePagin_Model::callMethoad()->createPaging($pagingArray);
       $pg = new Magic_CreatePagin_Model();
       $this->pagingVar = $pg->searchToolBar($tableDisplayField, $tableDisplayTitle, $value, $interval, $date1, $date2);
       $this->pagingVar .= $pg->createPaging($pagingArray_1);
    }
    
    
}
?>
